<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css/base2.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css/style2.css">
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
		<title>渠道商管理-渠道商列表</title>
	</head>
	<body>
		<div class="page">
			<div class="main_menu fl">
				<c:forEach items="${sessionScope.MENU_LIST}" var="mainMenu">
					<c:if test="${mainMenu.wOOpid == 2}">
						<div class="menu_name">
							<a href="${pageContext.request.contextPath}/${mainMenu.wOAction}"
								target="main"> <img
								src="${pageContext.request.contextPath}${mainMenu.wOIcon}">
								<p>${mainMenu.wOName}</p>
							</a>
						</div>
					</c:if>
				</c:forEach>
			</div>
				<div class="main_cont fl">
					<div class="main_cont_top">
						<div class="main_inner clearfix">
							
							<div class="cont_top_time fr"><i>
							<a href="javascript:window.location.reload();">
							<img src="${pageContext.request.contextPath}/images/images/refresh.png">刷新
							</a>
							</i></div>
						</div>
					</div>
					<div class="main_cont_top">
						<div class="main_inner clearfix">
							<div class="cont_top_time fr pr">
								<%-- <form action="${pageContext.request.contextPath}/supplier/list/pass/1.html">
									<input type="search" placeholder="请输入人渠道商名查询" class="search_txt" name="wSName"/>
									<input type="submit" value="搜索" class="search pa" style="top:6px;right: 0;">
								</form> --%>
							</div>
						</div>
					</div>
					<div class="main_cont_bottom_channelPass">
						<div class="main_inner">
							<ul class="main_cont_title clearfix" id="urlType">
								<li>
									<a href="${pageContext.request.contextPath}/supplier/list/all/1/1.html" 
									<c:if test="${flag eq 1}">
									class="on"
									</c:if>  >已通过</a>
								</li>
								<li>
									<a href="${pageContext.request.contextPath}/supplier/list/all/2/1.html" 
									<c:if test="${flag eq 2}">
									class="on"
									</c:if>  
									>待审核</a>
								</li>
							</ul>
							<div class="batch">
							<a onclick="datadel()">
							<img src="${pageContext.request.contextPath}/images/images/delete.png">批量删除
							</a>
							</div>
							<table>
							    <tr>
							    	<th><input type="checkbox" class="checked" id="checkAll"></th>
							        <th>渠道商编号</th> 
							        <th>渠道商名</th> 
							        <th>电话</th>
							        <th>联系人</th>
							        <th>所在城市</th> 
							        <th>所在区县</th> 
							        <th>具体地址</th>
							        <th>加入时间</th>
							        <th>状态</th> 
							        <th>操作</th>
							    </tr> 
							    
							    <c:forEach items="${PAGE_BEAN.dataList}" var="supplier">
							      <tr> 
							        <td><input type="checkbox" class="checked" value="${supplier.id}" name="idArray"></td> 
							        <td>${supplier.id }</td> 
							        <td>${supplier.wSName }</td>
							        <td>${supplier.wSTelephone }</td> 
							        <td>${supplier.wSContact }</td> 
							        <td>${supplier.wSCity }</td>
							        <td>${supplier.wSDistrict }</td> 
							        <td>${supplier.wSAddress }</td>
							        <td><fmt:formatDate value="${supplier.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
							        <td>
							    	<c:if test="${supplier.status eq 0}">
									停用
									</c:if>
									<c:if test="${supplier.status eq 1}">
									启用
									</c:if>
									<c:if test="${supplier.status eq 2}">
									待审核
									</c:if>  
									<c:if test="${supplier.status eq 3}">
									审核不通过
									</c:if>    
									<c:if test="${supplier.status eq 4}">
									审核通过
									</c:if>      
							       </td> 
							        <td>
							        <i>
									<a href="javascript:void(0)" onclick="start(${supplier.id })">启用</a>
									<a href="javascript:void(0)" onclick="stop(${supplier.id })">停用</a>
									</i>
							        <i>
							        <a href="${pageContext.request.contextPath}/supplier/detail/${supplier.id }.html">编辑</a>
							        </i>
							        <i>
							        <a href="javascript:void(0)" onclick="deleteOne(${supplier.id })">删除</a>
							        </i>
							        </td>
							    </tr> 
							    </c:forEach>
							
							</table> 
								<%@ include file="/WEB-INF/views/page.jsp"%>
						</div>
					</div>
				</div>
			</div>
		</div>
		
		<script type="text/javascript">

		function start(id){
			 if(id!=""){
				 $.ajax({
					 	url:"/supplier/start/"+id+".json",
						success: function(data){
							alert(data.info);
						}
					});
			 }
		}
		
		function stop(id){
			 if(id!=""){
				 $.ajax({
					 	url:"/supplier/stop/"+id+".json",
						success: function(data){
							alert(data.info);
						}
					});
			 }
		}
		
		function deleteOne(id){
			if(id!=""){
				 $.ajax({
					 	url:"/supplier/remove/"+id+".json",
						success: function(data){
							alert(data.info);
						}
					});
			}
		}
		
		/*渠道-删除*/
		function datadel(){
			    var chk_value =[];    
			      
				$('input[name="idArray"]:checked').each(function(){    
				   chk_value.push($(this).val()); 
				});
				
				if(chk_value.length==0){
					alert("请选择渠道商！");
					return false;
				}
				  
				var param = "";
				for(var i = 0; i < chk_value.length; i++) {
					param += chk_value[i] + "-";
				}
				
				$.ajax(
						{url:"/supplier/removeall/" + param + ".json",
						async:false,
						success: function(data){
							alert(data.info);
						}
				});
		}
		
	    $("#checkAll").bind("click", function () {
	    	$("[name=idArray]:checkbox").prop("checked", this.checked);
	    });

		$("input[name='idArray']").click(function() {
		    var $subs = $("input[name='idArray']");
			$("#checkAll").prop("checked",$subs.length == $subs.filter(":checked").length ? true : false);
		});


		
	
		</script>
		
	</body>
</html>
